< previous page page_392 next page >

Page 392
Writing to Properties
Besides just reading values from private data values in an object, youll also want to write information into these private data values. For this you need to create a Property Let procedure. A Property Let procedure is a subroutine that accepts one argumentthe value to set. The Property Let procedure should have the same name as the Property Get procedure. Lets add the appropriate Property Let routines to this class.
EXERCISE
Adding Property Let Procedures
1. Add the following Property Let procedures to the Employee class:
Property Let EmpID(ByVal lngEmpID As Long)
mlngEmpID = lngEmpID
End Property

Property Let FirstName(ByVal strValue As String)
mstrFirstName = strValue
End Property

Property Let LastName(ByVal strValue As String)
mstrLastName = strValue
End Property

Property Let Salary(ByVal curSalary As Currency)
mcurSalary = curSalary
End Property
analysis.gifThe Property Let code for FirstName is fired when you set a value in the FirstName property, the Property Let code for LastName is fired when you set a value in the LastName property, and so on.

9f31265bb40b592b1929e18a47ab28e5.gif
TIP
A
Property Let procedure always has one parameter thats passed to it. The parameter is not required to be passed by value, but its a good practice. Be aware that passing a parameter by value is much safer than passing it by reference. The parameters type must be the same data type as the return value from the Property Get procedure of the same name.

 
< previous page page_392 next page >

If you like this book, buy it!